#include "Predator.h"
#include "Timer.h"


#include <GL\glut.h>

Predator::Predator(Vec3f pos, int id)
{
	m_id = id;
	m_pos =pos;
	//srand (time(NULL));
	
}
Predator::Predator()
{
}
Predator::~Predator()
{
	
}

void Predator::Draw()
{
	glPushMatrix();

	glTranslatef(m_pos.X, m_pos.Y, m_pos.Z);

	glColor3f(.1,1,.3);
	glutSolidSphere(1,6,6);
	glPushMatrix();

	glTranslatef(0, 2, 0);
	glRotatef(270,1,0,0);
	glutSolidCone(.8,2,8,8);
	glPopMatrix();
	glPopMatrix();

}

void Predator::Update()
{
	//www.cplusplus.com/reference/cstdlib/rand/
	float dt = TheTimer::Instance()->GetDT();

	static int TheX =0;
	static int TheZ = 0;
	float Inc = 3 * dt;
	
	glColor3f(0,0,1);
	static int tester =0;
	tester++;
	
	//after a set number of updates generates a random number which acts a position 
	//for the the predator to move towards
	if(tester ==50)
	{
		TheX = rand() % 60 -30;
		TheZ = rand() % 60 -30;
		tester=0;
	}

	if(m_pos.X<TheX)
	{
		m_pos.X +=Inc;
	}
	if(m_pos.X>TheX)
	{
		m_pos.X -=Inc;
	}
	if(m_pos.Z<TheZ)
	{
		m_pos.Z +=Inc;
	}
	if(m_pos.Z>TheX)
	{
		m_pos.Z -=Inc;
	}

}

/*

#include <vector>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>

bool IsPrime(int i)
{
	std::vector<int> prenum;

	int j=2;
	while (j<i)
	{
		prenum.push_back(j);
		j++;
	}
	unsigned int k=0;

	while (k<prenum.size())
	{
		//float thesum;
		//thesum = j / prenum[k];
		if(j % prenum[k] ==0)
		{
			return false;
		}
		k++;
	}
	return true;
}

int main()
{

	while (1>0)
	{

		std::cout << "Enter a number to check if it is prime \n";
		int Input;
		std::cin >> Input;
		bool IsItPrime = IsPrime(Input);
		if(IsItPrime ==true)
		{
			std::cout << "Yes its prime \n";
		}
		else
		{
			std::cout << "No its not \n";
		}

	}
	return 0;
}
*/